﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="RefreshSummaryCommand.cs" company="Concept Architecture">
//   (c) 2010 Muhammad Umer Farooq
// </copyright>
// <summary>
//   Defines the  type.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace Hisaab.Client.Modules.Core.Dashboard.Commands
{
    using System;
    using System.Windows.Input;

    using Hisaab.Client.Modules.Core.Dashboard.ViewModel;

    /// <summary>
    /// Defines the <seealso cref="RefreshSummaryCommand"/> type.
    /// </summary>
    public class RefreshSummaryCommand : ICommand
    {
        #region Fields

        /// <summary>
        /// Member variable m_ViewModel
        /// </summary>
        private readonly SummaryBackStageTabViewModel _viewModel;

        #endregion Fields

        #region Constructor

        /// <summary>
        /// Initializes a new instance of the <see cref="RefreshSummaryCommand"/> class.
        /// </summary>
        /// <param name="viewModel">The view model.</param>
        public RefreshSummaryCommand(SummaryBackStageTabViewModel viewModel)
        {
            _viewModel = viewModel;
        }

        #endregion Constructor

        #region ICommand Members

        /// <summary>
        /// Occurs when changes occur that affect whether or not the command should execute.
        /// </summary>
        public event EventHandler CanExecuteChanged
        {
            add { CommandManager.RequerySuggested += value; }
            remove { CommandManager.RequerySuggested -= value; }
        }

        /// <summary>
        /// Defines the method that determines whether the command can execute in its current state.
        /// </summary>
        /// <param name="parameter">Data used by the command.  If the command does not require data to be passed, this object can be set to null.</param>
        /// <returns>
        /// true if this command can be executed; otherwise, false.
        /// </returns>
        public bool CanExecute(object parameter)
        {
            return true;
        }

        /// <summary>
        /// Executes the ShowModuleAViewCommand
        /// </summary>
        /// <param name="parameter">Data used by the command.  If the command does not require data to be passed, this object can be set to null.</param>
        public void Execute(object parameter)
        {
            _viewModel.ReloadSummary();
        }

        #endregion ICommand Members
    }
}